/*
 * @Sergii Donchenko, Kiev 2012
 * NeighbouringNumbers
 * Program to find Neighbouring Numbers
 */
 import java.util.*;
 public class NeighbouringNumbers 
 {
	public static void main(String[] arg)
	{
		Scanner in = new Scanner (System.in);
			
		System.out.print ("Write number of elements in array:");
		int numberOfElements = in.nextInt();
		
		int[] arrayNumber = new int[numberOfElements];
		
		if(arrayNumber.length < 2)
		{
			System.out.println ("So close, but not enough.");
			return;
		}
		
		System.out.println ("Fill array:");
		
		for (int count = 0; count < numberOfElements; count++)
		{
			System.out.print ("Array[" + count + "]:");
			int valueOfElement = in.nextInt();
			arrayNumber[count] = valueOfElement;
		}
		
				
		int firstCompare = Math.abs(arrayNumber[0] - arrayNumber[1]);
		int indexOfMinDistantion = 0;
		for (int arrayIndex = 1; arrayIndex < arrayNumber.length - 1; arrayIndex++)
		{
			if (firstCompare > (Math.abs(arrayNumber[arrayIndex] - arrayNumber[arrayIndex + 1])) )
			{
				firstCompare = (Math.abs(arrayNumber[arrayIndex] - arrayNumber[arrayIndex + 1]));
				indexOfMinDistantion = arrayIndex;
			}
		}
		System.out.println ("Index of min distantion:" + indexOfMinDistantion);
	}
}
		